﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Remoting.Messaging;
using MyProj.MVCProj3.IDAL;
namespace MyProj.MVCProj3.DAL
{
    public class DbSessionFactroy
    {


        public static IDbSession GetCurrentDbSession()
        {
            IDbSession _dbSession = (IDbSession)CallContext.GetData("DbSession");

            if (_dbSession == null)
            {
                //ModelContainer来自 MyProj.MVCProj3.Model项目的实体，需要首先编译MyProj.MVCProj3.Model，并在此项目中添加MyProj.MVCProj3.Model引用
                _dbSession = new DbSession();
                //
                CallContext.SetData("DbSession", _dbSession);
            }
            return _dbSession;
        }
    }
}
